
<template>
  <div id="editperson">
    <el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">
      <el-tab-pane label="基本情况" name="first">
        <div v-show="!editForm.Name">正在获取，请稍后...</div>
        <el-form :model="editForm" label-width="150px" :rules="editFormRules" ref="editForm" :inline="true" style="width:900px;float:left">
          <el-form-item label="姓名" prop="Name" style="width:370px;">
            <el-input v-model="editForm.Name" auto-complete="off"></el-input>
          </el-form-item>
          <el-form-item label="单位" prop="UnitName" style="width:500px;">
            <el-autocomplete class="inline-input" style="width:300px;" v-model="editForm.UnitName" :fetch-suggestions="querySearch" placeholder="单位关键字" :trigger-on-focus="false" ></el-autocomplete>
          </el-form-item>
          <el-form-item label="性别" prop="Sex" style="width:370px;">
            <el-radio v-model="editForm.Sex" label="男">男</el-radio>
            <el-radio v-model="editForm.Sex" label="女">女</el-radio>
          </el-form-item>
          <el-form-item label="身份证号" prop="IDNumber" style="width:500px;">
            <el-input v-model="editForm.IDNumber" auto-complete="off"></el-input>
          </el-form-item>
          <el-form-item label="民族" prop="Minzu" style="width:370px;">
            <el-select v-model="editForm.Minzu" placeholder="请选择民族" filterable style="width:202px">
              <el-option v-for="(item,index) in minzuoptions" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="籍贯" prop="Jiguan" style="width:500px;">
            <el-input v-model="editForm.Jiguan" auto-complete="off"></el-input>
          </el-form-item>
          <el-form-item label="出生地" prop="Chushengdi" style="width:370px;">
            <el-input v-model="editForm.Chushengdi" auto-complete="off"></el-input>
          </el-form-item>
          <el-form-item label="政治面貌" prop="Zhengzhimianmao" style="width:500px;">
            <el-select v-model="editForm.Zhengzhimianmao" placeholder="请选择政治面貌" filterable>
              <el-option v-for="(item,index) in zzoptions" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="入党时间" prop="Rudangshijian" style="width:370px;">
            <el-date-picker v-model="editForm.Rudangshijian" auto-complete="off"></el-date-picker>
          </el-form-item>
          <el-form-item label="参加工作时间" prop="Canjiagongzuoshijian" style="width:500px;">
            <el-date-picker v-model="editForm.Canjiagongzuoshijian" auto-complete="off"></el-date-picker>
          </el-form-item>
          <el-form-item label="专业技术职务" prop="Zhuanyezhiwu" style="width:370px;">
            <el-input v-model="editForm.Zhuanyezhiwu" auto-complete="off"></el-input>
          </el-form-item>
          <el-form-item label="健康状况" prop="Jiankangzhuangkuang" style="width:500px;">
            <el-select v-model="editForm.Jiankangzhuangkuang" placeholder="请选择健康状况">
              <el-option v-for="(item,index) in jiankangoptions" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="熟悉专业有何专长" prop="Zhuanyezhuanchang" style="width:800px;">
            <el-input v-model="editForm.Zhuanyezhuanchang" auto-complete="off" style="width:650px;"></el-input>
          </el-form-item>
          <h1>学位学历</h1>
          <el-form-item label="全日制教育学位" prop="QRZ_xuewei2">
            <el-cascader expand-trigger="hover" :options="xueweioptions" v-model="editForm.QRZ_xuewei2" :show-all-levels="false" filterable></el-cascader>
          </el-form-item>
          <el-form-item label="全日制教育学历" prop="QRZ_xueli2">
            <el-cascader expand-trigger="hover" :options="xuelioptions" v-model="editForm.QRZ_xueli2" :show-all-levels="false" filterable></el-cascader>
          </el-form-item>
          <el-form-item label="全日制教育院校专业" prop="QRZ_yuanxiaozhuaye" style="width:800px;">
            <el-input v-model="editForm.QRZ_yuanxiaozhuaye" auto-complete="off" style="width:650px;"></el-input>
          </el-form-item>
          <div style="clear:both"></div>
          <el-form-item label="在职教育学位" prop="ZZ_xuewei2">
            <el-cascader expand-trigger="hover" :options="xueweioptions" v-model="editForm.ZZ_xuewei2" :show-all-levels="false" filterable></el-cascader>
          </el-form-item>
          <el-form-item label="在职教育学历" prop="ZZ_xueli2">
            <el-cascader expand-trigger="hover" :options="xuelioptions" v-model="editForm.ZZ_xueli2" :show-all-levels="false" filterable></el-cascader>
          </el-form-item>
          <el-form-item label="在职教育院校专业" prop="ZZ_yuanxiaozhuaye" style="width:800px;">
            <el-input v-model="editForm.ZZ_yuanxiaozhuaye" auto-complete="off" style="width:650px;"></el-input>
          </el-form-item>
          <el-form-item label="奖惩情况" prop="Jiangchengqingkuang" style="width:1000px;">
            <el-input v-model="editForm.Jiangchengqingkuang" auto-complete="off" type="textarea" style="width:800px;"></el-input>
          </el-form-item>
          <el-form-item label="考核结果" prop="Kaohejieguo" style="width:1000px;">
            <el-input v-model="editForm.Kaohejieguo" auto-complete="off" type="textarea" style="width:800px;"></el-input>
          </el-form-item>
          <div style="clear:both; display:block;margin-left:150px;">
            <el-button type="primary" @click.native="editSubmit" :loading="formloading">保存</el-button>
            <el-button @click.native="backlist">返回</el-button>
          </div>
        </el-form>
        <el-upload
          class="avatar-uploader"
          :class="{disabled:mydisabled}"
          :action="this.$http.defaults.baseURL + 'person/uploadimg/' + this.$route.params.id"
          list-type="picture-card"
          :file-list="piclist"
          :on-preview="handlePictureCardPreview"
          :on-success="uploadsuccess"
          :before-remove="removepic"
          accept="image/jpeg, image/png"
          :before-upload="beforeAvatarUpload"
          with-credentials>
          <i class="el-icon-plus"></i>
        </el-upload>
        <el-dialog :visible.sync="dialogVisible">
          <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>
      </el-tab-pane>
      <el-tab-pane label="简历" name="second">
        <el-table :data="jianli" highlight-current-row v-loading="jianlilistLoading" style="width: 100%;">
          <el-table-column type="index" label="序号" width="70">
          </el-table-column>
          <el-table-column prop="Shijian" label="期间" width="250">
          </el-table-column>
          <el-table-column prop="Neirong" label="内容">
          </el-table-column>
          <el-table-column label="操作" width="150">
            <template slot-scope="scope">
              <el-button size="small" @click="jianliEdit(scope.row.Id)" type="primary">修改</el-button>
              <el-button size="small" @click="jianliDel(scope.row.Id)" type="danger">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
          <div style="clear:both; display:block;margin:20px;">
            <el-button @click.native="addjianli" type="primary">新增</el-button>
          </div>
        <!--新增简历界面-->
        <el-dialog title="新增简历信息" :visible.sync="addjianliFormVisible" >
          <el-form :model="addjianliForm" label-width="80px" :rules="addjianliFormRules" ref="addjianliForm">
            <el-form-item label="期间" prop="Shijian">
              <el-input v-model="addjianliForm.Shijian" placeholder="格式：2010年1月 至 2015年10月"></el-input>
            </el-form-item>
            <el-form-item label="内容" prop="Neirong">
              <el-input v-model="addjianliForm.Neirong" auto-complete="off"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="addjianliFormVisible = false">取消</el-button>
            <el-button type="primary" @click.native="addjianliSubmit" :loading="addjianliLoading">提交</el-button>
          </div>
        </el-dialog>
        <!--修改简历界面-->
        <el-dialog title="修改简历信息" :visible.sync="jianliEditFormVisible" >
          <el-form :model="jianliEditForm" label-width="80px" :rules="jianliEditFormRules" ref="jianliEditForm">
            <el-form-item label="期间" prop="Shijian">
              <el-input v-model="jianliEditForm.Shijian" placeholder="格式：2010年1月 至 2015年10月"></el-input>
            </el-form-item>
            <el-form-item label="内容" prop="Neirong">
              <el-input v-model="jianliEditForm.Neirong" auto-complete="off"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="jianliEditFormVisible = false">取消</el-button>
            <el-button type="primary" @click.native="jianliEditFormSubmit" :loading="jianliEditFormLoading">保存</el-button>
          </div>
        </el-dialog>
      </el-tab-pane>
      <el-tab-pane label="家庭成员" name="third">
        <el-table :data="jiating" highlight-current-row v-loading="jiatinglistLoading" style="width: 100%;">
          <el-table-column type="index" label="序号" width="70">
          </el-table-column>
          <el-table-column prop="Chengwei" label="称谓" width="100">
          </el-table-column>
          <el-table-column prop="Name" label="姓名" width="100">
          </el-table-column>
          <el-table-column prop="Birthday" label="出生日期" width="120" :formatter="dateFormat">
          </el-table-column>
          <el-table-column prop="Zhengzhimianmao" label="政治面貌" width="100">
          </el-table-column>
          <el-table-column prop="Gongzuodanweizhiwu" label="工作单位及职务">
          </el-table-column>
          <el-table-column label="操作" width="150">
            <template slot-scope="scope">
              <el-button size="small" @click="jiatingEdit(scope.row.Id)" type="primary">修改</el-button>
              <el-button size="small" @click="jiatingDel(scope.row.Id)" type="danger">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
          <div style="clear:both; display:block;margin:20px;">
            <el-button @click.native="addjiating" type="primary">新增</el-button>
          </div>
        <!--新增家庭成员界面-->
        <el-dialog title="新增家庭成员信息" :visible.sync="addjiatingFormVisible">
          <el-form :model="addjiatingForm" label-width="120px" :rules="addjiatingFormRules" ref="addjiatingForm">
            <el-form-item label="称谓" prop="Chengwei">
              <el-select v-model="addjiatingForm.Chengwei" placeholder="请选择称谓" filterable>
                <el-option v-for="(item,index) in chengweioptions" :key="index" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="姓名" prop="Name">
              <el-input v-model="addjiatingForm.Name" auto-complete="off" style="width:220px"></el-input>
            </el-form-item>
            <el-form-item label="出生日期" prop="Birthday">
              <el-date-picker v-model="addjiatingForm.Birthday" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
            <el-form-item label="政治面貌" prop="Zhengzhimianmao">
              <el-select v-model="addjiatingForm.Zhengzhimianmao" placeholder="请选择政治面貌" filterable>
                <el-option v-for="(item,index) in zzoptions" :key="index" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="工作单位及职务" prop="Gongzuodanweizhiwu">
              <el-input v-model="addjiatingForm.Gongzuodanweizhiwu" auto-complete="off" style="width:620px"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="addjiatingFormVisible = false">取消</el-button>
            <el-button type="primary" @click.native="addjiatingSubmit" :loading="addjiatingLoading">保存</el-button>
          </div>
        </el-dialog>
        <!--修改家庭成员界面-->
        <el-dialog title="修改家庭成员信息" :visible.sync="jiatingEditFormVisible">
          <el-form :model="jiatingEditForm" label-width="120px" :rules="jiatingEditFormRules" ref="jiatingEditForm">
            <el-form-item label="称谓" prop="Chengwei">
              <el-select v-model="jiatingEditForm.Chengwei" placeholder="请选择称谓" filterable>
                <el-option v-for="(item,index) in chengweioptions" :key="index" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="姓名" prop="Name">
              <el-input v-model="jiatingEditForm.Name" auto-complete="off" style="width:220px"></el-input>
            </el-form-item>
            <el-form-item label="出生日期" prop="Birthday">
              <el-date-picker v-model="jiatingEditForm.Birthday" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
            <el-form-item label="政治面貌" prop="Zhengzhimianmao">
              <el-select v-model="jiatingEditForm.Zhengzhimianmao" placeholder="请选择政治面貌" filterable>
                <el-option v-for="(item,index) in zzoptions" :key="index" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="工作单位及职务" prop="Gongzuodanweizhiwu" style="width:620px">
              <el-input v-model="jiatingEditForm.Gongzuodanweizhiwu" auto-complete="off"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click.native="jiatingEditFormVisible = false">取消</el-button>
            <el-button type="primary" @click.native="jiatingEditFormSubmit" :loading="jiatingEditFormLoading">保存</el-button>
          </div>
        </el-dialog>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import getunits from '@/js/common.js'
export default {
  name: 'HelloWorld',
  data () {
    return {
      formloading: false,
      imageUrl: '',
      activeName: 'first',
      editForm: {
        Name: ''
      },
      editForm1: {
        Name: ''
      },
      editForm2: {
        Name: ''
      },
      editFormRules: {
        Name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        Sex: [{ required: true, message: '请选择性别', trigger: 'blur' }],
        IDNumber: [{ required: true, message: '请输入身份证号', trigger: 'blur' }],
        Jiguan: [{ required: true, message: '请输入籍贯', trigger: 'blur' }],
        Chushengdi: [{ required: true, message: '请输入出生地', trigger: 'blur' }],
        Canjiagongzuoshijian: [{ required: true, message: '请输入参加工作时间', trigger: 'blur' }],
        Minzu: [{ required: true, message: '请选择民族', trigger: 'blur' }],
        Zhengzhimianmao: [{ required: true, message: '请选择政治面貌', trigger: 'blur' }],
        Jiankangzhuangkuang: [{ required: true, message: '请选择健康状况', trigger: 'blur' }]
      },
      editLoading: false,
      bzlistLoading: false,
      bz: [],
      dialogImageUrl: '',
      dialogVisible: false,
      mydisabled: false,
      piclist: [],
      jiankangoptions: [],
      zzoptions: [],
      minzuoptions: [],
      minzuLoading: false,
      xuelioptions: [],
      xueliLoading: false,
      xueweioptions: [],
      xueweiLoading: false,
      jiating: [],
      jiatinglistLoading: false,
      jianli: [],
      jianlilistLoading: false,
      renzhi: [],
      renzhilistLoading: false,
      addjianliForm: {},
      addjianliFormRules: {
        Shijian: [{ required: true, message: '请输入期间', trigger: 'blur' }],
        Neirong: [{ required: true, message: '请输入内容', trigger: 'blur' }]
      },
      addjianliFormVisible: false,
      addjianliLoading: false,
      jianliEditForm: {},
      jianliEditFormRules: {
        Shijian: [{ required: true, message: '请输入期间', trigger: 'blur' }],
        Neirong: [{ required: true, message: '请输入内容', trigger: 'blur' }]
      },
      jianliEditFormVisible: false,
      jianliEditFormLoading: false,
      addjiatingForm: {},
      addjiatingFormRules: {
        Chengwei: [{ required: true, message: '请选择称谓', trigger: 'blur' }],
        Name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        Birthday: [{ required: true, message: '请选择出生日期', trigger: 'blur' }],
        Zhengzhimianmao: [{ required: true, message: '请选择政治面貌', trigger: 'blur' }],
        Gongzuodanweizhiwu: [{ required: true, message: '请输入工作单位及职务', trigger: 'blur' }]
      },
      addjiatingFormVisible: false,
      addjiatingLoading: false,
      jiatingEditForm: {},
      jiatingEditFormRules: {
        Chengwei: [{ required: true, message: '请选择称谓', trigger: 'blur' }],
        Name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        Birthday: [{ required: true, message: '请选择出生日期', trigger: 'blur' }],
        Zhengzhimianmao: [{ required: true, message: '请选择政治面貌', trigger: 'blur' }],
        Gongzuodanweizhiwu: [{ required: true, message: '请输入工作单位及职务', trigger: 'blur' }]
      },
      jiatingEditFormVisible: false,
      jiatingEditFormLoading: false,
      chengweioptions: {}
    }
  },
  methods: {
    querySearch (queryString, cb) {
      return getunits(this, queryString, cb)
    },
    dateFormat: function (row, column) {
      const daterc = row[column.property]
      if (daterc === undefined) {
        return ''
      }
      if (daterc != null) {
        const dateMat = new Date(daterc)
        const year = dateMat.getFullYear()
        const month = dateMat.getMonth() + 1
        const day = dateMat.getDate()
        const timeFormat = year + '-' + month + '-' + day
        return timeFormat
      }
    },
    uploadsuccess () {
      this.mydisabled = true
      console.log('zhi:' + this.mydisabled)
    },
    beforeAvatarUpload (file) {
      const isJPG = file.type === 'image/jpeg'
      const isLt2M = file.size / 1024 / 1024 < 0.5
      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!')
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 500k!')
      }
      return isJPG && isLt2M
    },
    handleClick (tab, event) {
      console.log(tab, event)
    },
    handlePictureCardPreview (file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    removepic () {
      var _this = this
      this.mydisabled = false
      this.$http.post(`/person/removeimg/` + this.$route.params.id).then(function (response) {
        _this.listLoading = false
        if (response.data.IsSuccess === true) {
          console.log('删除照片成功')
        } else {
          console.log('删除照片失败:' + response.data.Msg)
          _this.$message({
            message: '删除照片失败:' + response.data.Msg,
            type: 'error'
          })
        }
      }).catch(function (error) {
        console.log(error)
        _this.$message({
          message: '获取失败:' + error,
          type: 'error'
        })
      })
    },
    getPersonDetail () {
      let para = {
        id: this.$route.params.id
      }
      var _this = this
      this.listLoading = true
      this.$http
        .post(`/person/details`, para)
        .then(function (response) {
          console.log(para)
          _this.listLoading = false
          if (response.data.IsSuccess === true) {
            console.log('获取成功')
            _this.editForm = response.data.Result
            _this.jianli = response.data.Result.PersonJianLi
            _this.jiating = response.data.Result.Family
            _this.renzhi = response.data.Result.Renzhis
            if (response.data.Result.Picture) {
              let mypic = {
                name: response.data.Result.Name + '.jpg',
                url: 'data:image/jpeg;base64,' + response.data.Result.Picture
              }
              _this.piclist.push(mypic)
              _this.mydisabled = true
            }
          } else {
            console.log('获取失败:' + response.data.Msg)
            _this.$message({
              message: '获取失败:' + response.data.Msg,
              type: 'error'
            })
          }
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    getDics () {
      let para = {
        id: this.$route.params.id
      }
      var _this = this
      this.minzuLoading = true
      this.$http
        .post(`/person/dics`)
        .then(function (response) {
          console.log(para)
          _this.minzuLoading = false
          if (response.data.IsSuccess === true) {
            console.log('获取成功')
            _this.minzuoptions = response.data.Result.Minzu
            _this.jiankangoptions = response.data.Result.Jiankang
            _this.zzoptions = response.data.Result.Zhengzhimianmao
            _this.chengweioptions = response.data.Result.Chengwei
            _this.xuelioptions = response.data.Result.Xueli
            console.log('学历信息')
            console.log(_this.xuelioptions)
            _this.xueweioptions = response.data.Result.Xuewei
          } else {
            console.log('获取失败:' + response.data.Msg)
            _this.$message({
              message: '获取失败:' + response.data.Msg,
              type: 'error'
            })
          }
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    editSubmit: function () {
      var _this = this
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          _this.formloading = true
          let para = {
            id: this.$route.params.id,
            Name: this.editForm.Name,
            UnitName: this.editForm.UnitName,
            Sex: this.editForm.Sex,
            IDNumber: this.editForm.IDNumber,
            Minzu: this.editForm.Minzu,
            Jiguan: this.editForm.Jiguan,
            Chushengdi: this.editForm.Chushengdi,
            Rudangshijian: this.editForm.Rudangshijian,
            Zhengzhimianmao: this.editForm.Zhengzhimianmao,
            Canjiagongzuoshijian: this.editForm.Canjiagongzuoshijian,
            Jiankangzhuangkuang: this.editForm.Jiankangzhuangkuang,
            Zhuanyezhiwu: this.editForm.Zhuanyezhiwu,
            Zhuanyezhuanchang: this.editForm.Zhuanyezhuanchang,
            QRZ_xuewei2: this.editForm.QRZ_xuewei2,
            QRZ_xueli2: this.editForm.QRZ_xueli2,
            QRZ_yuanxiaozhuaye: this.editForm.QRZ_yuanxiaozhuaye,
            ZZ_xuewei2: this.editForm.ZZ_xuewei2,
            ZZ_xueli2: this.editForm.ZZ_xueli2,
            ZZ_yuanxiaozhuaye: this.editForm.ZZ_yuanxiaozhuaye,
            Jiangchengqingkuang: this.editForm.Jiangchengqingkuang,
            Kaohejieguo: this.editForm.Kaohejieguo
          }
          this.$http.post(`/person/edit`, para).then(function (response) {
            console.log(response.data.IsSuccess)
            if (response.data.IsSuccess === true) {
              _this.formloading = false
              _this.$message({
                message: '保存成功',
                type: 'success'
              })
            } else {
              _this.formloading = false
              console.log('保存失败:' + response.data.Msg)
              _this.$message({
                message: '保存失败:' + response.data.Msg,
                type: 'error'
              })
            }
          }).catch(function (error) {
            console.log(error)
            _this.formloading = false
            _this.$message({
              message: '获取失败:' + error,
              type: 'error'
            })
          })
        }
      })
    },
    backlist () {
      this.$router.push('/person/')
    },
    jiatingDel: function (id) {
      this.$confirm('确认删除该家庭成员吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.jiatinglistLoading = true
        let para = { id: id }
        this.$http.post(`/person/deleteFamily`, para).then((response) => {
          this.jiatinglistLoading = false
          if (response.data.IsSuccess === true) {
            console.log('删除成功')
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.jiating = response.data.Result
          } else {
            console.log('删除失败:' + response.data.Msg)
            this.$message({
              message: '删除失败:' + response.data.Msg,
              type: 'error'
            })
          }
        })
      }).catch(() => {
      })
    },
    jianliDel: function (id) {
      this.$confirm('确认删除该经历信息吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.jianlilistLoading = true
        let para = { id: id }
        this.$http.post(`/person/deleteJianli`, para).then((response) => {
          this.jianlilistLoading = false
          if (response.data.IsSuccess === true) {
            console.log('删除成功')
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.jianli = response.data.Result
          } else {
            console.log('删除失败:' + response.data.Msg)
            this.$message({
              message: '删除失败:' + response.data.Msg,
              type: 'error'
            })
          }
        })
      }).catch(() => {
      })
    },
    addjianli: function () {
      console.log('开启新增简历界面')
      this.addjianliFormVisible = true
      this.addjianliForm = {
        Shijian: '',
        Neirong: ''
      }
    },
    jianliEdit: function (id) {
      console.log('开启修改简历界面' + id)
      this.getjianliDetail(id)
    },
    getjianliDetail: function (id) {
      for (var i = 0; i < this.jianli.length; i++) {
        if (this.jianli[i].Id === id) {
          let objData = Object.assign({}, this.jianli[i])
          this.jianliEditForm = objData
          this.jianliEditFormVisible = true
          break
        }
      }
    },
    // 新增简历提交
    addjianliSubmit: function () {
      var _this = this
      this.$refs.addjianliForm.validate((valid) => {
        if (valid) {
          _this.addjianliLoading = true
          let para = {
            Shijian: this.addjianliForm.Shijian,
            Neirong: this.addjianliForm.Neirong,
            pId: this.$route.params.id
          }
          this.$http.post(`/person/addJianli`, para).then(function (response) {
            console.log(response.data.IsSuccess)
            if (response.data.IsSuccess === true) {
              _this.addjianliLoading = false
              _this.$message({
                message: '提交成功',
                type: 'success'
              })
              _this.jianli = response.data.Result
            } else {
              console.log('提交失败:' + response.data.Msg)
              _this.$message({
                message: '提交失败:' + response.data.Msg,
                type: 'error'
              })
            }
            _this.$refs['addjianliForm'].resetFields()
            _this.addjianliFormVisible = false
          }).catch(function (error) {
            console.log(error)
            _this.$message({
              message: '提交失败:' + error,
              type: 'error'
            })
          })
        }
      })
    },
    // 修改简历提交
    jianliEditFormSubmit: function () {
      var _this = this
      this.$refs.jianliEditForm.validate((valid) => {
        if (valid) {
          _this.jianliEditFormLoading = true
          let para = {
            Shijian: _this.jianliEditForm.Shijian,
            Neirong: _this.jianliEditForm.Neirong,
            Id: _this.jianliEditForm.Id,
            personId: _this.$route.params.id
          }
          this.$http.post(`/person/editJianli`, para).then(function (response) {
            console.log(response.data.IsSuccess)
            if (response.data.IsSuccess === true) {
              _this.jianliEditFormLoading = false
              _this.$message({
                message: '保存成功',
                type: 'success'
              })
              _this.jianli = response.data.Result
            } else {
              console.log('保存失败:' + response.data.Msg)
              _this.$message({
                message: '保存失败:' + response.data.Msg,
                type: 'error'
              })
            }
            _this.$refs['jianliEditForm'].resetFields()
            _this.jianliEditFormVisible = false
          }).catch(function (error) {
            console.log(error)
            _this.$message({
              message: '保存失败:' + error,
              type: 'error'
            })
          })
        }
      })
    },
    addjiating: function () {
      this.addjiatingFormVisible = true
      this.addjiatingForm = {
        chengwei: '',
        name: '',
        nianling: '',
        zhengzhimianmao: '',
        gongzuodanwei: ''
      }
    },
    jiatingEdit: function (id) {
      this.getjiatingDetail(id)
    },
    getjiatingDetail: function (id) {
      for (var i = 0; i < this.jiating.length; i++) {
        if (this.jiating[i].Id === id) {
          let objData = Object.assign({}, this.jiating[i])
          this.jiatingEditForm = objData
          this.jiatingEditFormVisible = true
          break
        }
      }
    },
    // 新增家庭成员提交
    addjiatingSubmit: function () {
      var _this = this
      console.log('干部id' + this.$route.params.id)
      this.$refs.addjiatingForm.validate((valid) => {
        if (valid) {
          _this.addjiatingLoading = true
          let para = {
            Chengwei: this.addjiatingForm.Chengwei,
            Name: this.addjiatingForm.Name,
            Birthday: this.addjiatingForm.Birthday,
            Zhengzhimianmao: this.addjiatingForm.Zhengzhimianmao,
            Gongzuodanweizhiwu: this.addjiatingForm.Gongzuodanweizhiwu,
            pId: this.$route.params.id
          }
          this.$http.post(`/person/addFamily`, para).then(function (response) {
            console.log(response.data.IsSuccess)
            if (response.data.IsSuccess === true) {
              _this.addjiatingLoading = false
              _this.$message({
                message: '提交成功',
                type: 'success'
              })
              _this.jiating = response.data.Result
            } else {
              console.log('提交失败:' + response.data.Msg)
              _this.$message({
                message: '提交失败:' + response.data.Msg,
                type: 'error'
              })
            }
            _this.$refs['addjiatingForm'].resetFields()
            _this.addjiatingFormVisible = false
          }).catch(function (error) {
            console.log(error)
            _this.$message({
              message: '提交失败:' + error,
              type: 'error'
            })
          })
        }
      })
    },
    // 修改家庭成员提交
    jiatingEditFormSubmit: function () {
      var _this = this
      this.$refs.jiatingEditForm.validate((valid) => {
        if (valid) {
          _this.jiatingEditFormLoading = true
          console.log('家庭成员id')
          console.log(this.jiatingEditForm.Id)
          let para = {
            Chengwei: this.jiatingEditForm.Chengwei,
            Name: this.jiatingEditForm.Name,
            Birthday: this.jiatingEditForm.Birthday,
            Zhengzhimianmao: this.jiatingEditForm.Zhengzhimianmao,
            Gongzuodanweizhiwu: this.jiatingEditForm.Gongzuodanweizhiwu,
            Id: this.jiatingEditForm.Id,
            personId: this.$route.params.id
          }
          this.$http.post(`/person/editFamily`, para).then(function (response) {
            console.log(response.data.IsSuccess)
            if (response.data.IsSuccess === true) {
              _this.jiatingEditFormLoading = false
              _this.$message({
                message: '保存成功',
                type: 'success'
              })
              _this.jiating = response.data.Result
            } else {
              console.log('保存失败:' + response.data.Msg)
              _this.$message({
                message: '保存失败:' + response.data.Msg,
                type: 'error'
              })
            }
            _this.$refs['jiatingEditForm'].resetFields()
            _this.jiatingEditFormVisible = false
          }).catch(function (error) {
            console.log(error)
            _this.$message({
              message: '保存失败:' + error,
              type: 'error'
            })
          })
        }
      })
    }
  },
  mounted () {
    this.getPersonDetail()
    this.getDics()
  }
}
</script>
<style>
.el-cascader-menu{
  width: 220px
}
.disabled .el-upload--picture-card {
    display: none;
}
#editperson{
  padding:20px;
}
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    text-align: center;
  }
  .avatar {
    display: block;
  }
  .avatar-uploader .el-upload-list__item{
    width: 178px !important;
    height: 230px !important;
  }
</style>
